package com.example.demo.controller;
import com.example.demo.comm.ApiJsonResp;
import com.example.demo.service.SchoolCodeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;
import java.util.List;
@RestController
@RequestMapping("/Hello")
public class HelloController
{
    @Autowired
    JdbcTemplate jdbcTemplate;
    @Autowired
    private SchoolCodeService schoolCodeService;
    @GetMapping("")
    public ApiJsonResp<?>  hello() {
        ApiJsonResp<?> resp = new ApiJsonResp<>();
        resp.setData(111);
        resp.IsOK();
        return resp;
    }
    @GetMapping("/all")
    public List<Map<String,Object>> list() {
        String sql = "select * from school_code";
        return jdbcTemplate.queryForList(sql);
    }

    @GetMapping("/code/list")
    public ApiJsonResp<?> AddSchoolCodeRecord(){
        ApiJsonResp<?> resp = new ApiJsonResp<>();
        resp.setData(schoolCodeService.GetAllList().toArray());
        resp.IsOK();
        return resp;
    }

}
